// import Cookies from 'js-cookie'

const TokenKey = 'hrsaas-ihrm-token' // 设置一个独一无二的key
const timeKey = 'hrsaas-timestamp-key' // 设置一个独一无二的key

// export function getToken() {
//   return Cookies.get(TokenKey)
// }

// export function setToken(token) {
//   return Cookies.set(TokenKey, token)
// }

// export function removeToken() {
//   return Cookies.remove(TokenKey)
// }

export function getToken(TokenKey) {
  const data = window.localStorage.getItem(TokenKey)
  try {
    return JSON.parse(data)
  } catch (err) {
    return data
  }
}

export function setToken(token) {
  if (typeof value === 'object') {
    token = JSON.stringify(token)
  }
  window.localStorage.setItem(TokenKey, token)
}

export function removeToken() {
  window.localStorage.removeItem(TokenKey)
}

// 读时间戳
export function getTimeStamp() {
  // return Cookies.get(timeKey)
  return window.localStorage.getItem(timeKey)
}

// 设置时间戳
export function setTimeStamp() {
  // return Cookies.set(timeKey, Date.now())
  window.localStorage.setItem(timeKey, Date.now())
}
